import request from '@/utils/request'

/**
 * SpreadJS文件上传
 * @param {File} file 文件对象
 */
export function uploadSpreadJSFile(file) {
  const formData = new FormData()
  formData.append('file', file)
  
  return request({
    url: '/tool/spreadjs/upload',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

/**
 * SpreadJS文件下载
 * @param {String} resource 文件路径
 */
export function downloadSpreadJSFile(resource) {
  return process.env.VUE_APP_BASE_API + '/tool/spreadjs/download?resource=' + encodeURIComponent(resource)
}
